<template>
  <z-modal
    :width="1250"
    :visible="visible"
    :title="title"
    destroyOnClose
    switchFullscreen
    @ok="handleSubmit('1')"
    @cancel="close"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading" class="jeecg-form-container-disabled">
      <a-form-model layout="horizontal" labelAlign="right" ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol" :model="form">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="合同名称" prop="name">
              <a-input placeholder="请输入合同名称" v-model.trim="form.name" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" prop="customerName">
              <a-input placeholder="请输入客户名称" v-model.trim="form.customerName" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="销售机会" prop="saleChance">
              <a-input placeholder="请输入销售机会" v-model.trim="form.saleChance" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="业务类型" prop="businessType">
              <z-dict-select-tag v-model="form.businessType"  dictCode="business_type" placeholder="请选择业务类型"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="合同总价" prop="money">
              <a-input-number placeholder="请输入合同总价" v-model.trim="form.money" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="签订日期" prop="orderDate">
              <a-date-picker v-model="form.orderDate"  placeholder="请选择签订日期" style="width: 100%"  showTime format="YYYY-MM-DD HH:mm:ss" @change="(value,dateString) =>{ this.form.orderDate = dateString}"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="是否开票" prop="billed">
              <z-dict-select-tag v-model="form.billed"  dictCode="MB_SYSTEM_YES_NO" placeholder="请选择是否开票"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="合同负责人" prop="ownerUserId">
              <ZSelectUserByDep :multi="false" v-model="form.ownerUserId" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="所属公司" prop="company">
              <a-input placeholder="请输入所属公司" v-model.trim="form.company" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="备注" prop="remark">
              <a-input placeholder="请输入备注" v-model.trim="form.remark" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
    <template slot="footer">
      <a-button  @click="handleCancel">取消</a-button>
      <a-button type="primary" @click="checkStatus('2')">拒绝</a-button>
      <a-button type="primary" @click="checkStatus('1')">通过</a-button>
    </template>
  </z-modal>
</template>

<script>
import ModalFormMixin from '@/mixins/ModalFormMixin'
import ZDictSelectTag from '@/components/dict/ZDictSelectTag'
import ZSelectUserByDep from '@/components/zzbiz/ZSelectUserByDep'
import { httpAction } from '@/services/manage'

export default {
  name: "CheckContractModal",
  mixins: [ModalFormMixin],
  components: {
    ZDictSelectTag,
    ZSelectUserByDep,
  },
  data() {
    return {
      title: '合同审核',
      loading: false,
      form: {},
      visible: false,
      url: {
        checkStatus: '/contract/checkStatus'
      },
      // 查询参数
      queryParam: {},
      selectedRowKeys: [],
      selectedRows: [],
      toggleSearchStatus: false
    }
  },
  methods: {
    showModal(record) {
      this.visible = true
      this.form = Object.assign({}, record)
    },
    close() {
      this.visible = false
    },
    handleSubmit(status) {
      const that = this;
      let formData = Object.assign({}, this.form)
      formData.checkStatus = status
      httpAction(this.url.checkStatus, formData, 'put').then((res)=>{
        if(res.success){
          that.$message.success(res.message);
          this.close()
        }else{
          that.$message.warning(res.message);
        }
      }).finally(() => {
          that.confirmLoading = false;
        })
      
    },
    checkStatus(status){
      this.handleSubmit(status);
    }
  }
}
</script>
<style>
.jeecg-form-container-disabled{
    cursor: not-allowed;
    -ms-pointer-events: none;
    pointer-events: none;
}
</style>
